home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1199 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  72 lines

  1. Newsgroups: comp.lang.c
  2. Path: netcom.com!maverick
  3. From: maverick@netcom.com (Chris Shepard)
  4. Subject: Re: Locaton of an array?
  5. Message-ID: <maverickDL1u3x.45I@netcom.com>
  6. Sender: maverick@netcom6.netcom.com
  7. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  8. X-Newsreader: Forte Free Agent 1.0.82
  9. References: <4d4iqk$hs3@overload.lbl.gov>
  10. Date: Fri, 12 Jan 1996 03:39:47 GMT
  11.  
  12. Hi,
  13.      Haven't actually coded this in a long time, but try....
  14.  
  15. #include <the usual stuff>
  16.  
  17. int main(void)
  18. {
  19.     char arr[10],
  20.               *p;
  21.  
  22.     p=arr;
  23.     printf("addr of arr = %p\n",p);
  24.     return(EXIT_SUCCESS);
  25. }
  26.  
  27. Btw, just  out of curiosity, why do you care where it lives in
  28. absolute RAM?
  29.  
  30.      Cheers.
  31.  
  32.  
  33. Mikhail Faiguenblat <mfaiguen> wrote:
  34.  
  35. >I am sure this has been answered a million times by now, but could someody help
  36. >me, please?
  37.  
  38. >I have an array in my program, and I need to find out the absolute location in
  39. >memory where this array is located. 
  40. >I have tried to do it this way:
  41.  
  42. >#include <stdio.h>
  43.  
  44. >int main() {
  45. >    char arr[10];
  46. >    int addr;
  47.  
  48. >    printf("sizeof(char *) = %d\n", sizeof(char *));
  49. >    printf("sizeof(int) = %d\n", sizeof(int));
  50.  
  51. >    addr = arr;
  52.  
  53. >    printf("addr = %d\n", addr);
  54.  
  55. >    return 0;
  56. >}
  57.  
  58. >And it did not work:
  59.  
  60. >sizeof(char *) = 4
  61. >sizeof(int) = 4
  62. >addr = 2063810808
  63.  
  64. >Obviously, the computer I run it on does not have 2Gb memory, so I must be
  65. >doing something wrong.
  66. >Can anybody help me?
  67.  
  68. >Mikhail
  69.  
  70.  
  71.  
  72.